﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ServerNodeGui
{
	public partial class ServerOptionsDialog : Form
	{
		public ServerOptionsDialog()
		{
			InitializeComponent();
		}

		protected override void OnLoad(EventArgs e)
		{
			base.OnLoad(e);
			txtResultPath.Text = BatchResultsFolder;
		}

		public String BatchResultsFolder;

		private void btnBrowse_Click(object sender, EventArgs e)
		{
			OpenFileDialog ofd = new OpenFileDialog();
			FolderBrowserDialog fbd = new FolderBrowserDialog();
			fbd.ShowNewFolderButton = true;
			if (fbd.ShowDialog() == DialogResult.OK)
			{
				txtResultPath.Text = fbd.SelectedPath;
			}
		}

		private void btnOK_Click(object sender, EventArgs e)
		{
			try
			{
				if (System.IO.Directory.Exists(txtResultPath.Text) == false)
					throw new ArgumentException("Directory does not exist");
				BatchResultsFolder = txtResultPath.Text;
				this.DialogResult = DialogResult.OK;
				this.Close();
			}
			catch (ArgumentException ex)
			{
				lblError.Text = "Error: " + ex.Message;
			}
		}

		private void btnCancel_Click(object sender, EventArgs e)
		{
			this.DialogResult = DialogResult.Cancel;
			this.Close();
		}
	}
}
